home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Development Platforms / CSMP Digests / csmp-v1-031.txt < prev    next >
Encoding:
Text File  |  1992-11-18  |  42.6 KB  |  1,304 lines  |  [TEXT/MPS ]

  1. C.S.M.P. Digest             Thu, 26 Mar 92       Volume 1 : Issue 31
  2.  
  3. Today's Topics:
  4.  
  5.     Pointer arithmatic in Pascal question
  6.     Code modules in a program - how to implement?
  7.     How do you write an MDEF that handles scrolling?
  8.     Select Directory dialog
  9.     Where's that code frag that finds the app file ?
  10.  
  11.  
  12. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  13.  
  14. These digests are available (by using FTP, account anonymous, your email
  15. address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
  16. edu.  This is also the home of the comp.sys.mac.programmer Frequently Asked
  17. Questions list.
  18.  
  19. These digests are also available via email.  Just send a note saying that you
  20. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  21. automatically receive each new digest as it is created.
  22.  
  23. The articles in these digests are taken directly from comp.sys.mac.programmer.
  24. They are not edited; all articles included in this digest are in their original
  25. posted form.  The only articles that are -not- included in these digests are
  26. those which didn't receive any replies (except those that give information
  27. rather than ask a question).  All replies to each article are concatenated
  28. onto the original article in the order in which they were received.  Article
  29. threads are not added to the digests until the last article added to the
  30. thread is at least one month old (this is to ensure that the thread is dead
  31. before adding it to the digests).
  32.  
  33. Send administrative mail to mkelly@cs.uoregon.edu.
  34.  
  35. -------------------------------------------------------
  36.  
  37. From: vivanco@ciit85.ciit.nrc.ca
  38. Subject: Pointer arithmatic in Pascal question
  39. Date: 27 Jan 92 11:17:14 GMT
  40. Organization: National Research Council
  41.  
  42. Hi, I usually program in C where pointer arithmatic is widely used. Now, I
  43. need a variable 2D array of integers. In C, I would allocate a 1D array and
  44. use pointer arithmatic to acces the array as a 2D array. Can you do a similar
  45. thing in Pascal? 
  46.  
  47. Thanks in advance,
  48.  
  49. Rodrigo
  50.  
  51.  
  52.  
  53. - -------------------------
  54.  
  55. From: jmatthews@desire.wright.edu
  56. Subject:  Pointer arithmatic in Pascal question
  57. Date: 29 Jan 92 04:42:20 GMT
  58. Organization: Wright State University
  59.  
  60. In article <1992Jan27.171715.1088@ciit85.ciit.nrc.ca>, vivanco@ciit85.ciit.nrc.ca writes:
  61. > Hi, I usually program in C where pointer arithmatic is widely used. Now, I
  62. > need a variable 2D array of integers. In C, I would allocate a 1D array and
  63. > use pointer arithmatic to acces the array as a 2D array. Can you do a similar
  64. > thing in Pascal? 
  65.  
  66. Depending on the nature of your data, Pascal may provide more elegant
  67. solutions, but pointer arithmetic works fine in Pascal. To avaiod heap
  68. fragmentation, allocate space with Newhandle, call MoveHHi and HLock it.
  69. Call StripAddress on the handle's master pointer and use that as the base of
  70. the array. Calling ord() on a pointer renders a LongInt, and calling pointer()
  71. on a LongInt is assignment compatible with any pointer type.
  72.  
  73. type IntPtr = ^Integer;
  74. const xDim = columns-1; yDim = rows-1;
  75. var h: Handle; p: IntPtr;
  76. ...
  77. h:= NewHandle(xDim*yDim*2);
  78. if h <> nil then
  79.   begin
  80.     MoveHHi(h);
  81.     HLock(h);
  82.     p:= IntPtr(StripAddress(h^))
  83.   end
  84. else p:= nil;
  85. ...
  86. procedure SetArray(p:IntPtr; x,y,i:Integer; {p^[x,y]:=i}
  87. begin
  88.   p:= IntPtr(ord(p) + y*xDim*2 + x*2); {or however you want to base the array}
  89.   p^:= i
  90. end;
  91. ...
  92. function GetArray(p:IntPtr; x,y:Integer):Integer;
  93. begin
  94.   p:= IntPtr(ord(p) + y*xDim*2 + x*2); {or however you want to base the array}
  95.   GetArray:= p^
  96. end;
  97.  
  98. Range checking is left as an exercise. Hope this helps.
  99.  
  100. o----------------------------------------------------------------------------o
  101. | John B. Matthews, jmatthews@desire.wright.edu, disclaimer:= myViews <> WSU |
  102. | "I'm a commensal .sig virus, indistinguishable from an ordinary organelle."|
  103. o----------------------------------------------------------------------------o
  104.  
  105.  
  106.  
  107. - -------------------------
  108.  
  109. From: keith@Apple.COM (Keith Rollin)
  110. Subject:  Pointer arithmatic in Pascal question
  111. Date: 30 Jan 92 22:52:28 GMT
  112. Organization: Apple Computer Inc., Cupertino, CA
  113.  
  114. In article <1992Jan28.234220.1589@desire.wright.edu> jmatthews@desire.wright.edu writes:
  115. >In article <1992Jan27.171715.1088@ciit85.ciit.nrc.ca>, vivanco@ciit85.ciit.nrc.ca writes:
  116. >> Hi, I usually program in C where pointer arithmatic is widely used. Now, I
  117. >> need a variable 2D array of integers. In C, I would allocate a 1D array and
  118. >> use pointer arithmatic to acces the array as a 2D array. Can you do a similar
  119. >> thing in Pascal? 
  120. >
  121. >Depending on the nature of your data, Pascal may provide more elegant
  122. >solutions, but pointer arithmetic works fine in Pascal. To avaiod heap
  123. >fragmentation, allocate space with Newhandle, call MoveHHi and HLock it.
  124. >Call StripAddress on the handle's master pointer and use that as the base of
  125. >the array. Calling ord() on a pointer renders a LongInt, and calling pointer()
  126. >on a LongInt is assignment compatible with any pointer type.
  127.  
  128. I'd suggest taking a little different approach the one described above.
  129. Given the original poster's needs, there should be no need to move the
  130. handle high in the heap, lock it, or call StripAddress on the master
  131. pointer. On the other hand, there are several reason why you shouldn't
  132. call those routines. Instead, assuming an array of integers, use
  133. something like the following:
  134.  
  135. TYPE
  136.     IntArray = ARRAY [0..0] OF INTEGER;    { actually variable sized }
  137.     IntArrayPtr = ^IntArray;
  138.     IntArrayHdl = ^IntArrayPtr;
  139.  
  140. VAR
  141.     myArray: IntArrayHdl;
  142.  
  143. BEGIN
  144.     myArray = IntArrayHdl(NewHandle(someSize));
  145.     { now initialize all elements to one. }
  146.     for i := 0 to width do begin
  147.         for j := 0 to height do begin
  148.         {$PUSH} {$R-} {turn off range checking}
  149.         myArray^^[j*width+i] := 1;
  150.         {$POP} {restore previsous settings}
  151.         end;
  152.     end;
  153. END.
  154.  
  155. This is just off the top of my head, so I hope I'm not too far off.
  156.  
  157. -- 
  158. - ----------------------------------------------------------------------------
  159. Keith Rollin           ---            <Taligent .signature under construction>
  160. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  161.  
  162.  
  163.  
  164. - -------------------------
  165.  
  166. From: vivanco@ciit85.ciit.nrc.ca
  167. Subject:  Pointer arithmatic in P (Thanks)
  168. Date: 4 Feb 92 04:40:21 GMT
  169. Organization: National Research Council
  170.  
  171. In article <1992Jan28.234220.1589@desire.wright.edu>, jmatthews@desire.wright.edu writes:
  172. > In article <1992Jan27.171715.1088@ciit85.ciit.nrc.ca>, vivanco@ciit85.ciit.nrc.ca writes:
  173. >> Hi, I usually program in C where pointer arithmatic is widely used. Now, I
  174. >> need a variable 2D array of integers. In C, I would allocate a 1D array and
  175. >> use pointer arithmatic to acces the array as a 2D array. Can you do a similar
  176. >> thing in Pascal? 
  177. > Depending on the nature of your data, Pascal may provide more elegant
  178. > solutions, but pointer arithmetic works fine in Pascal. To avaiod heap
  179. > fragmentation, allocate space with Newhandle, call MoveHHi and HLock it.
  180. > Call StripAddress on the handle's master pointer and use that as the base of
  181. > the array. Calling ord() on a pointer renders a LongInt, and calling pointer()
  182. > on a LongInt is assignment compatible with any pointer type.
  183. > type IntPtr = ^Integer;
  184. > const xDim = columns-1; yDim = rows-1;
  185. > var h: Handle; p: IntPtr;
  186. > ...
  187. > h:= NewHandle(xDim*yDim*2);
  188. > if h <> nil then
  189. >   begin
  190. >     MoveHHi(h);
  191. >     HLock(h);
  192. >     p:= IntPtr(StripAddress(h^))
  193. >   end
  194. > else p:= nil;
  195. > ...
  196. > procedure SetArray(p:IntPtr; x,y,i:Integer; {p^[x,y]:=i}
  197. > begin
  198. >   p:= IntPtr(ord(p) + y*xDim*2 + x*2); {or however you want to base the array}
  199. >   p^:= i
  200. > end;
  201. > ...
  202. > function GetArray(p:IntPtr; x,y:Integer):Integer;
  203. > begin
  204. >   p:= IntPtr(ord(p) + y*xDim*2 + x*2); {or however you want to base the array}
  205. >   GetArray:= p^
  206. > end;
  207. > Range checking is left as an exercise. Hope this helps.
  208. > o----------------------------------------------------------------------------o
  209. > | John B. Matthews, jmatthews@desire.wright.edu, disclaimer:= myViews <> WSU |
  210. > | "I'm a commensal .sig virus, indistinguishable from an ordinary organelle."|
  211. > o----------------------------------------------------------------------------o
  212.  
  213. Thanks, that's the way I did it. Except I typed cast the pointer into a Longint
  214. and then back. The reason I asked was that in C you can declare a pointer and
  215. use it like an array, syntax wise. The compiler takes care of addressing
  216. depending on the size of an element. Thanks toIngemar Ragnemalm for a similar 
  217. suggestion.
  218.  
  219. Rodrigo.
  220.  
  221.  
  222.  
  223. - -------------------------
  224.  
  225. From: dent@DIALix.oz.au (Andrew Dent)
  226. Subject:  Pointer arithmatic in P (Thanks)
  227. Date: 7 Feb 92 13:50:06 GMT
  228. Organization: DIALix Services, Perth, Western Australia
  229.  
  230. To save type-casting for pointer increments, I wrote the following
  231. library. Note that it costs a LITTLE in performance, pushing the arguments
  232. on the stack, compared to straight addition code, but may be worth it for
  233. readability:
  234.  
  235. Andy - share and enjoy!
  236.  
  237. unit ptrTools;
  238. { functions for incrementing and decrementing various 2 and 4 byte values }
  239. {  EG:  incP(aPtr)      nextPtr:=plus1P(aPtr)        less4I(integerToDecrease) }
  240.  
  241. { copyright 1990 A.D. Software, free for all use provided this }
  242. { copyright notice retained }
  243.  
  244. { "Ad ware" - other products that may interest you:  }
  245. { Shareware: Fast File Compare }
  246. { Freeware: various Hypercard & FoxBASE+/Mac XCMDS, including }
  247. {setting SF open/save path, get monitor bit depth etc. }
  248. { and Think Pascal Code & Resource for an Open dialog with prompt string }
  249.  
  250. { Retail: Fortran->Pascal translator and Fortran formatted}
  251.  {I/O runtime libraries.  }
  252. { COMING SOON - classified magazine entry/management/printing system }
  253.  
  254. {Andy Dent                          A.D. Software phone/fax 61-9-249-2719 }
  255. {    Mac & VAX programmer           94 Bermuda Dve , Ballajura}
  256. {    Internet: dent@dialix.oz.au    Western Australia 6066}
  257. {    Compuserve: 100033,3241 }
  258.  
  259. { NOTE:  if you want to increase the constants (up to 8) then change }
  260. {  the second digit of the SUBQ or ADDQ line }
  261. {  ADD is even, 0=8  2=1  4=2  6=3  8=4  A=5  C=6  E=7 }
  262. {  SUB is odd,   1=8  3=1  5=2  7=3  9=4  B=5  D=6  F=7 }
  263.  
  264.  
  265. interface
  266.  
  267.  
  268. {************************************************************}
  269. {                   L O N G I N T                            }
  270. {************************************************************}
  271.  
  272. {             F U N C T I O N S                         }
  273.  
  274.  function Plus1L (l: longint): longint;
  275.  inline
  276.   $5297, {ADDQ.L #$1, (A7) }
  277.   $2E9F;  {MOVE.L (A7)+, (A7) }
  278.  
  279.  function Plus2L (l: longint): longint;
  280.  inline
  281.   $5497, {ADDQ.L #$2, (A7) }
  282.   $2E9F;  {MOVE.L (A7)+, (A7) }
  283.  
  284.  function Plus3L (l: longint): longint;
  285.  inline
  286.   $5697, {ADDQ.L #$3, (A7) }
  287.   $2E9F;  {MOVE.L (A7)+, (A7) }
  288.  
  289.  function Plus4L (l: longint): longint;
  290.  inline
  291.   $5897, {ADDQ.L #$4, (A7) }
  292.   $2E9F;  {MOVE.L (A7)+, (A7) }
  293.  
  294.  
  295.  function Less1L (l: longint): longint;
  296.  inline
  297.   $5397, {SUBQ.L #$1, (A7) }
  298.   $2E9F;  {MOVE.L (A7)+, (A7) }
  299.  
  300.  function Less2L (l: longint): longint;
  301.  inline
  302.   $5597, {SUBQ.L #$2, (A7) }
  303.   $2E9F;  {MOVE.L (A7)+, (A7) }
  304.  
  305.  function Less3L (l: longint): longint;
  306.  inline
  307.   $5797, {SUBQ.L #$3, (A7) }
  308.   $2E9F;  {MOVE.L (A7)+, (A7) }
  309.  
  310.  function Less4L (l: longint): longint;
  311.  inline
  312.   $5997, {SUBQ.L #$4, (A7) }
  313.   $2E9F;  {MOVE.L (A7)+, (A7) }
  314.  
  315.  
  316.  
  317.  
  318. {                   P R O C E D U R E S                      }
  319.  procedure incL (var l: longint);
  320.  inline
  321.   $205f, {MOVEA.L (A7)+, A0 }
  322.   $5290; {ADDQ.L #$1, (A0) }
  323.  
  324.  procedure inc2L (var l: longint);
  325.  inline
  326.   $205f, {MOVEA.L (A7)+, A0 }
  327.   $5490; {ADDQ.L #$2, (A0) }
  328.  
  329.  procedure inc3L (var l: longint);
  330.  inline
  331.   $205f, {MOVEA.L (A7)+, A0 }
  332.   $5690; {ADDQ.L #$3, (A0) }
  333.  
  334.  procedure inc4L (var l: longint);
  335.  inline
  336.   $205f, {MOVEA.L (A7)+, A0 }
  337.   $5890; {ADDQ.L #$4, (A0) }
  338.  
  339.  
  340.  procedure decL (var l: longint);
  341.  inline
  342.   $205f, {MOVEA.L (A7)+, A0 }
  343.   $5390; {SUBQ.L #$1, (A0) }
  344.  
  345.  procedure dec2L (var l: longint);
  346.  inline
  347.   $205f, {MOVEA.L (A7)+, A0 }
  348.   $5590; {SUBQ.L #$2, (A0) }
  349.  
  350.  procedure dec3L (var l: longint);
  351.  inline
  352.   $205f, {MOVEA.L (A7)+, A0 }
  353.   $5790; {SUBQ.L #$3, (A0) }
  354.  
  355.  procedure dec4L (var l: longint);
  356.  inline
  357.   $205f, {MOVEA.L (A7)+, A0 }
  358.   $5990; {SUBQ.L #$4, (A0) }
  359.  
  360.  
  361.  
  362. {***********************************************}
  363. {                    P T R                      }
  364. {***********************************************}
  365.  
  366. {                    F U N C T I O N S           }
  367.  function Plus1P (p: univ ptr): ptr;
  368.  inline
  369.   $5297, {ADDQ.L #$1, (A7) }
  370.   $2E9F;  {MOVE.P (A7)+, (A7) }
  371.  
  372.  function Plus2P (p: univ ptr): ptr;
  373.  inline
  374.   $5497, {ADDQ.L #$2, (A7) }
  375.   $2E9F;  {MOVE.P (A7)+, (A7) }
  376.  
  377.  function Plus3P (p: univ ptr): ptr;
  378.  inline
  379.   $5697, {ADDQ.L #$3, (A7) }
  380.   $2E9F;  {MOVE.P (A7)+, (A7) }
  381.  
  382.  function Plus4P (p: univ ptr): ptr;
  383.  inline
  384.   $5897, {ADDQ.L #$4, (A7) }
  385.   $2E9F;  {MOVE.P (A7)+, (A7) }
  386.  
  387.  
  388.  function Less1P (p: univ ptr): ptr;
  389.  inline
  390.   $5397, {SUBQ.L #$1, (A7) }
  391.   $2E9F;  {MOVE.P (A7)+, (A7) }
  392.  
  393.  function Less2P (p: univ ptr): ptr;
  394.  inline
  395.   $5597, {SUBQ.L #$2, (A7) }
  396.   $2E9F;  {MOVE.P (A7)+, (A7) }
  397.  
  398.  function Less3P (p: univ ptr): ptr;
  399.  inline
  400.   $5797, {SUBQ.L #$3, (A7) }
  401.   $2E9F;  {MOVE.P (A7)+, (A7) }
  402.  
  403.  function Less4P (p: univ ptr): ptr;
  404.  inline
  405.   $5997, {SUBQ.L #$4, (A7) }
  406.   $2E9F;  {MOVE.P (A7)+, (A7) }
  407.  
  408.  
  409.  
  410.  
  411. {                       P R O C E D U R E S                    }
  412.  procedure incP (var p: ptr);
  413.  inline
  414.   $205f, {MOVEA.P (A7)+, A0 }
  415.   $5290; {ADDQ.L #$1, (A0) }
  416.  
  417.  procedure inc2P (var p: ptr);
  418.  inline
  419.   $205f, {MOVEA.P (A7)+, A0 }
  420.   $5490; {ADDQ.L #$2, (A0) }
  421.  
  422.  procedure inc3P (var p: ptr);
  423.  inline
  424.   $205f, {MOVEA.P (A7)+, A0 }
  425.   $5690; {ADDQ.L #$3, (A0) }
  426.  
  427.  procedure inc4P (var p: ptr);
  428.  inline
  429.   $205f, {MOVEA.P (A7)+, A0 }
  430.   $5890; {ADDQ.L #$4, (A0) }
  431.  
  432.  
  433.  procedure decP (var p: ptr);
  434.  inline
  435.   $205f, {MOVEA.P (A7)+, A0 }
  436.   $5390; {SUBQ.L #$1, (A0) }
  437.  
  438.  procedure dec2P (var p: ptr);
  439.  inline
  440.   $205f, {MOVEA.P (A7)+, A0 }
  441.   $5590; {SUBQ.L #$2, (A0) }
  442.  
  443.  procedure dec3P (var p: ptr);
  444.  inline
  445.   $205f, {MOVEA.P (A7)+, A0 }
  446.   $5790; {SUBQ.L #$3, (A0) }
  447.  
  448.  procedure dec4P (var p: ptr);
  449.  inline
  450.   $205f, {MOVEA.P (A7)+, A0 }
  451.   $5990; {SUBQ.L #$4, (A0) }
  452.  
  453.  
  454.  
  455.  
  456. {**************************************************}
  457. {                 I N T E G E R                    }
  458. {**************************************************}
  459.  
  460. {                     F U N C T I O N S            }
  461.  function Plus1I (i: integer): integer;
  462.  inline
  463.   $5257, {ADDQ.W #$1, (A7) }
  464.   $3E9F;  {MOVE.W (A7)+, (A7) }
  465.  
  466.  function Plus2I (i: integer): integer;
  467.  inline
  468.   $5457, {ADDQ.W #$2, (A7) }
  469.   $3E9F;  {MOVE.W (A7)+, (A7) }
  470.  
  471.  function Plus3I (i: integer): integer;
  472.  inline
  473.   $5657, {ADDQ.W #$3, (A7) }
  474.   $3E9F;  {MOVE.W (A7)+, (A7) }
  475.  
  476.  function Plus4I (i: integer): integer;
  477.  inline
  478.   $5857, {ADDQ.W #$4, (A7) }
  479.   $3E9F;  {MOVE.W (A7)+, (A7) }
  480.  
  481.  
  482.  function Less1I (i: integer): integer;
  483.  inline
  484.   $5357, {SUBQ.W #$1, (A7) }
  485.   $3E9F;  {MOVE.W (A7)+, (A7) }
  486.  
  487.  function Less2I (i: integer): integer;
  488.  inline
  489.   $5557, {SUBQ.W #$2, (A7) }
  490.   $3E9F;  {MOVE.W (A7)+, (A7) }
  491.  
  492.  function Less3I (i: integer): integer;
  493.  inline
  494.   $5757, {SUBQ.W #$3, (A7) }
  495.   $3E9F;  {MOVE.W (A7)+, (A7) }
  496.  
  497.  function Less4I (i: integer): integer;
  498.  inline
  499.   $5957, {SUBQ.W #$4, (A7) }
  500.   $3E9F;  {MOVE.W (A7)+, (A7) }
  501.  
  502.  
  503.  
  504.  
  505. {                   P R O C E D U R E S                          }
  506.  procedure incI (var i: integer);
  507.  inline
  508.   $205f, {MOVEA.W (A7)+, A0 }
  509.   $5250; {ADDQ.W #$1, (A0) }
  510.  
  511.  procedure inc2I (var i: integer);
  512.  inline
  513.   $205f, {MOVEA.W (A7)+, A0 }
  514.   $5450; {ADDQ.W #$2, (A0) }
  515.  
  516.  procedure inc3I (var i: integer);
  517.  inline
  518.   $205f, {MOVEA.W (A7)+, A0 }
  519.   $5650; {ADDQ.W #$3, (A0) }
  520.  
  521.  procedure inc4I (var i: integer);
  522.  inline
  523.   $205f, {MOVEA.W (A7)+, A0 }
  524.   $5850; {ADDQ.W #$4, (A0) }
  525.  
  526.  
  527.  procedure decI (var i: integer);
  528.  inline
  529.   $205f, {MOVEA.W (A7)+, A0 }
  530.   $5350; {SUBQ.W #$1, (A0) }
  531.  
  532.  procedure dec2I (var i: integer);
  533.  inline
  534.   $205f, {MOVEA.W (A7)+, A0 }
  535.   $5550; {SUBQ.W #$2, (A0) }
  536.  
  537.  procedure dec3I (var i: integer);
  538.  inline
  539.   $205f, {MOVEA.W (A7)+, A0 }
  540.   $5750; {SUBQ.W #$3, (A0) }
  541.  
  542.  procedure dec4I (var i: integer);
  543.  inline
  544.   $205f, {MOVEA.W (A7)+, A0 }
  545.   $5950; {SUBQ.W #$4, (A0) }
  546.  
  547. implementation
  548. end.
  549.  
  550.  
  551.  
  552. - -------------------------
  553.  
  554. From: keith@Apple.COM (Keith Rollin)
  555. Subject:  Pointer arithmatic in Pascal question
  556. Date: 30 Jan 92 22:52:28 GMT
  557. Organization: Apple Computer Inc., Cupertino, CA
  558.  
  559. In article <1992Jan28.234220.1589@desire.wright.edu> jmatthews@desire.wright.edu writes:
  560. >In article <1992Jan27.171715.1088@ciit85.ciit.nrc.ca>, vivanco@ciit85.ciit.nrc.ca writes:
  561. >> Hi, I usually program in C where pointer arithmatic is widely used. Now, I
  562. >> need a variable 2D array of integers. In C, I would allocate a 1D array and
  563. >> use pointer arithmatic to acces the array as a 2D array. Can you do a similar
  564. >> thing in Pascal? 
  565. >
  566. >Depending on the nature of your data, Pascal may provide more elegant
  567. >solutions, but pointer arithmetic works fine in Pascal. To avaiod heap
  568. >fragmentation, allocate space with Newhandle, call MoveHHi and HLock it.
  569. >Call StripAddress on the handle's master pointer and use that as the base of
  570. >the array. Calling ord() on a pointer renders a LongInt, and calling pointer()
  571. >on a LongInt is assignment compatible with any pointer type.
  572.  
  573. I'd suggest taking a little different approach the one described above.
  574. Given the original poster's needs, there should be no need to move the
  575. handle high in the heap, lock it, or call StripAddress on the master
  576. pointer. On the other hand, there are several reason why you shouldn't
  577. call those routines. Instead, assuming an array of integers, use
  578. something like the following:
  579.  
  580. TYPE
  581.     IntArray = ARRAY [0..0] OF INTEGER;    { actually variable sized }
  582.     IntArrayPtr = ^IntArray;
  583.     IntArrayHdl = ^IntArrayPtr;
  584.  
  585. VAR
  586.     myArray: IntArrayHdl;
  587.  
  588. BEGIN
  589.     myArray = IntArrayHdl(NewHandle(someSize));
  590.     { now initialize all elements to one. }
  591.     for i := 0 to width do begin
  592.         for j := 0 to height do begin
  593.         {$PUSH} {$R-} {turn off range checking}
  594.         myArray^^[j*width+i] := 1;
  595.         {$POP} {restore previsous settings}
  596.         end;
  597.     end;
  598. END.
  599.  
  600. This is just off the top of my head, so I hope I'm not too far off.
  601.  
  602. -- 
  603. - ----------------------------------------------------------------------------
  604. Keith Rollin           ---            <Taligent .signature under construction>
  605. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  606.  
  607.  
  608.  
  609. ---------------------------
  610.  
  611. From: mhall@occs.cs.oberlin.edu (Matthew Hall)
  612. Subject: Code modules in a program - how to implement?
  613. Date: 28 Jan 92 21:05:43 GMT
  614. Organization: Oberlin College Computer Science
  615.  
  616. Hello -
  617.     My question is this - How can I write a program that will, at
  618. run time, load a code resource, and pass information to it, and then
  619. have the code resource return to the original program, passing more
  620. information.  I am thinking along the lines of Mandelzot, where
  621. the program acts as a shell almost and programmers can create their
  622. own modules to do what they want.  
  623.     I assume I will have to use assembly - which is not too good
  624. for me, but if I don't need to do too much I can use Think Pascal's
  625. inline assembler.  Also, it seems, I can not use global variables or
  626. call new() or dispose() frome the code - but I can probably deal with
  627. that. Would it be a question of loading the code resoursce, locking
  628. it, pushing the variables onto the stack, and then jumping to the code
  629. resources handle? (The code resource would be structured like a DA or
  630. CDEV - one procedure at the start of the code that takes messages and
  631. information and passes them on)  Am I being way too naive?  Can you
  632. help me? Please respond.
  633.  
  634. Matt Hall
  635. mhall@occs.edu
  636. --
  637.  
  638. <<mhall@occs.edu OR
  639. <<SMH9666@OBERLIN.BITNET
  640.  
  641. This is just a beta version signature
  642.  
  643.  
  644.  
  645. - -------------------------
  646.  
  647. From: mhall@occs.cs.oberlin.edu (Matthew Hall)
  648. Subject: Code Modules - how to use.
  649. Date: 29 Jan 92 21:43:57 GMT
  650. Organization: Oberlin College Computer Science
  651.  
  652.  
  653.     I have had several inquiries for a followup since I asked my
  654. question of how to call, at runtime, other code resources that were
  655. not linked to the main program at compile time.  These can be written
  656. by other programmers to add different functions or effects to a main
  657. program - MandelZot and IFS (I think) use this so that programmers can
  658. add new fractal algorithms.
  659.     The only response that I have had so far is to look in Tech
  660. Note #256.  It's availible in the Tech Note Stack from ftp.apple.com
  661. or individually at archive.umich.edu
  662. (/mac/development/apple/tech.notes/tn.251.300) 
  663. I haven't had a chance to download it yet. (I tried downloading the
  664. TNStack a few weeks ago, but it got corrupted in the process, and
  665. destroyed my system 7 folder when I tried to unstuff it.  That's okay,
  666. I was getting sick of Sys 7 anyways.  And the neat thing is, alaises I
  667. made under Sys 7 work under sys 6.0.7.  But I digress)
  668.     Anyway, if anyone else has more information, please reply and
  669. I will summarize.
  670.  
  671. Thank you-
  672. Matt Hall
  673.  
  674. --
  675.  
  676. <<mhall@occs.edu OR
  677. <<SMH9666@OBERLIN.BITNET
  678.  
  679. This is just a beta version signature
  680.  
  681.  
  682.  
  683. - -------------------------
  684.  
  685. From: keith@Apple.COM (Keith Rollin)
  686. Subject:  Code modules in a program - how to implement?
  687. Date: 30 Jan 92 22:21:01 GMT
  688. Organization: Apple Computer Inc., Cupertino, CA
  689.  
  690. In article <MHALL.92Jan28160543@occs.cs.oberlin.edu> mhall@occs.cs.oberlin.edu (Matthew Hall) writes:
  691. >Hello -
  692. >    My question is this - How can I write a program that will, at
  693. >run time, load a code resource, and pass information to it, and then
  694. >have the code resource return to the original program, passing more
  695. >information.  I am thinking along the lines of Mandelzot, where
  696. >the program acts as a shell almost and programmers can create their
  697. >own modules to do what they want.  
  698. >    I assume I will have to use assembly - which is not too good
  699. >for me, but if I don't need to do too much I can use Think Pascal's
  700. >inline assembler.  Also, it seems, I can not use global variables or
  701. >call new() or dispose() frome the code - but I can probably deal with
  702. >that. Would it be a question of loading the code resoursce, locking
  703. >it, pushing the variables onto the stack, and then jumping to the code
  704. >resources handle? (The code resource would be structured like a DA or
  705. >CDEV - one procedure at the start of the code that takes messages and
  706. >information and passes them on)  Am I being way too naive?  Can you
  707. >help me? Please respond.
  708.  
  709. I guess you're using Pascal, but this is easier in C, so I'll show
  710. it first.
  711.  
  712. Assume you want to call a function with the following declaration:
  713.  
  714. long myFunc(short, long);
  715.  
  716. Further assume that this function is in the external resource PROC(1),
  717. with the entry point at the first byte of the resource. You would then
  718. use the following code to call it:
  719.  
  720. typedef long (*MyFuncPtr)(short, long);
  721.  
  722. Handle    myCode;
  723.  
  724. myCode = GetResource('PROC', 1);
  725. myLongResult = ((MyFuncPtr) *myCode)(myShort, myLong);
  726.  
  727. In Pascal, it is more difficult to deal with function pointers.  I
  728. believe that you would have to use something like the following:
  729.  
  730. FUNCTION CallExternal(someInteger: INTEGER; someLong: LONGINT;
  731.             someProc: Ptr): LONGINT;
  732.     INLINE $205F,        { MOVE.L (A7)+,A0 }
  733.            $4E90;        { JSR    (A0)     }
  734.  
  735. myCode:    Handle;
  736.  
  737. myCode := GetResource('PROC', 1);
  738. myLongResult := CallExternal(myInteger, myLong, myCode^);
  739.  
  740. My Pascal is a little rusty, so I hope I'm not too far off.
  741.  
  742. -- 
  743. - ----------------------------------------------------------------------------
  744. Keith Rollin           ---            <Taligent .signature under construction>
  745. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  746.  
  747.  
  748.  
  749. - -------------------------
  750.  
  751. From: CXT105@psuvm.psu.edu (Christopher Tate)
  752. Subject:  Code modules in a program - how to implement?
  753. Date: 31 Jan 92 02:46:26 GMT
  754. Organization: Penn State University
  755.  
  756. In article <62297@apple.Apple.COM>, keith@Apple.COM (Keith Rollin) says:
  757. >
  758. >Assume you want to call a function with the following declaration:
  759. >
  760. >long myFunc(short, long);
  761. >
  762. >Further assume that this function is in the external resource PROC(1),
  763. >with the entry point at the first byte of the resource. You would then
  764. >use the following code to call it:
  765. >
  766. >typedef long (*MyFuncPtr)(short, long);
  767. >
  768. >Handle  myCode;
  769. >
  770. >myCode = GetResource('PROC', 1);
  771. >myLongResult = ((MyFuncPtr) *myCode)(myShort, myLong);
  772.  
  773. Shouldn't you flush the caches between the GetResource() and the function
  774. call so as not to terminally confuse a Quadra?
  775.  
  776. Or am I completely off base on just when you should and shouldn't flush
  777. the caches?  The subject has come up recently, but I haven't seen any
  778. explanation of *when* this sort of thing is necessary.  Maybe it's time
  779. for something like the "When to call StripAddress()" tech note....
  780.  
  781. - -----
  782. Christopher Tate     | Cryptogram #16:
  783. cxt105@psuvm.psu.edu |
  784. CXT105@PSUVM.BITNET  |   JUI EKO AJ BKSI OJPF JZM NKF FPU YIAAIF
  785. - -------------------|   XV AJ ZJJS PQ ALI QFXNI JC K UIE JUI.
  786. Send me the answer!  |
  787.  
  788.  
  789.  
  790. - -------------------------
  791.  
  792. From: thomp@netcom.COM (Thom Phillabaum)
  793. Subject:  Code modules in a program - how to implement?
  794. Date: 31 Jan 92 21:08:15 GMT
  795. Organization: Netcom - Online Communication Services  (408 241-9760 guest)
  796.  
  797. One small, somewhat subtle detail is that you should also lock the handle to
  798. the CODE resource.  Otherwise, if the CODE resource makes any toolbox call
  799. the Memory Manager is likely to scoot things around (including the code it's
  800. executing) when compacting the heap.  Needless to say, this would be a
  801. sub-optimal situation.  Anyway, that's my two bits... 
  802.  
  803. thomp@netcom.com
  804.  
  805.  
  806.  
  807. - -------------------------
  808.  
  809. From: keith@Apple.COM (Keith Rollin)
  810. Subject:  Code modules in a program - how to implement?
  811. Date: 3 Feb 92 03:09:52 GMT
  812. Organization: Apple Computer Inc., Cupertino, CA
  813.  
  814. In article <92030.214626CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes:
  815. >In article <62297@apple.Apple.COM>, keith@Apple.COM (Keith Rollin) says:
  816. >>
  817. >>Assume you want to call a function with the following declaration:
  818. >>
  819. >>long myFunc(short, long);
  820. >>
  821. >>Further assume that this function is in the external resource PROC(1),
  822. >>with the entry point at the first byte of the resource. You would then
  823. >>use the following code to call it:
  824. >>
  825. >>typedef long (*MyFuncPtr)(short, long);
  826. >>
  827. >>Handle  myCode;
  828. >>
  829. >>myCode = GetResource('PROC', 1);
  830. >>myLongResult = ((MyFuncPtr) *myCode)(myShort, myLong);
  831. >
  832. >Shouldn't you flush the caches between the GetResource() and the function
  833. >call so as not to terminally confuse a Quadra?
  834. >
  835. >Or am I completely off base on just when you should and shouldn't flush
  836. >the caches?  The subject has come up recently, but I haven't seen any
  837. >explanation of *when* this sort of thing is necessary.  Maybe it's time
  838. >for something like the "When to call StripAddress()" tech note....
  839.  
  840. You're completely correct in that the instruction cache should be
  841. cleared when loading in a resource with executable code in it.
  842. Fortunately, GetResource and LoadResource do this for you.
  843.  
  844. Flushing the instruction cache is necessary if you whip up instructions
  845. on the fly. For instance, a common method for implementing things like
  846. custom control and menus includes utilizing a 6 byte resource. The
  847. first word of the resource contains a JMP instruction, and the
  848. following long word gets filled in by the application with the address
  849. of the application function that implements the 'real' defProc code.
  850. After this address is written, the instruction cache should be
  851. flushed. On the other hand, if the JMP $xxxxxxxx instruction in the
  852. resource were replaced with something like the following, you wouldn't
  853. need to worry about flushing the cache:
  854.  
  855. MyMDEF    PROC
  856.  
  857.     LEA    Address,A0
  858.     MOVE.L    (A0),A0
  859.     JMP    (A0)
  860. Address    DC.L    0        ; Get's filled in by application
  861.                 ; after resource is loaded.
  862.     ENDP
  863.  
  864. (I can't remember if the first two instructions can be shortened to
  865. a mere MOVE.L Address,A0 so please excuse any verbosity.)
  866.  
  867. -- 
  868. - ----------------------------------------------------------------------------
  869. Keith Rollin           ---            <Taligent .signature under construction>
  870. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  871.  
  872.  
  873.  
  874. - -------------------------
  875.  
  876. From: keith@Apple.COM (Keith Rollin)
  877. Subject:  Code modules in a program - how to implement?
  878. Date: 30 Jan 92 22:21:01 GMT
  879. Organization: Apple Computer Inc., Cupertino, CA
  880.  
  881. In article <MHALL.92Jan28160543@occs.cs.oberlin.edu> mhall@occs.cs.oberlin.edu (Matthew Hall) writes:
  882. >Hello -
  883. >    My question is this - How can I write a program that will, at
  884. >run time, load a code resource, and pass information to it, and then
  885. >have the code resource return to the original program, passing more
  886. >information.  I am thinking along the lines of Mandelzot, where
  887. >the program acts as a shell almost and programmers can create their
  888. >own modules to do what they want.  
  889. >    I assume I will have to use assembly - which is not too good
  890. >for me, but if I don't need to do too much I can use Think Pascal's
  891. >inline assembler.  Also, it seems, I can not use global variables or
  892. >call new() or dispose() frome the code - but I can probably deal with
  893. >that. Would it be a question of loading the code resoursce, locking
  894. >it, pushing the variables onto the stack, and then jumping to the code
  895. >resources handle? (The code resource would be structured like a DA or
  896. >CDEV - one procedure at the start of the code that takes messages and
  897. >information and passes them on)  Am I being way too naive?  Can you
  898. >help me? Please respond.
  899.  
  900. I guess you're using Pascal, but this is easier in C, so I'll show
  901. it first.
  902.  
  903. Assume you want to call a function with the following declaration:
  904.  
  905. long myFunc(short, long);
  906.  
  907. Further assume that this function is in the external resource PROC(1),
  908. with the entry point at the first byte of the resource. You would then
  909. use the following code to call it:
  910.  
  911. typedef long (*MyFuncPtr)(short, long);
  912.  
  913. Handle    myCode;
  914.  
  915. myCode = GetResource('PROC', 1);
  916. myLongResult = ((MyFuncPtr) *myCode)(myShort, myLong);
  917.  
  918. In Pascal, it is more difficult to deal with function pointers.  I
  919. believe that you would have to use something like the following:
  920.  
  921. FUNCTION CallExternal(someInteger: INTEGER; someLong: LONGINT;
  922.             someProc: Ptr): LONGINT;
  923.     INLINE $205F,        { MOVE.L (A7)+,A0 }
  924.            $4E90;        { JSR    (A0)     }
  925.  
  926. myCode:    Handle;
  927.  
  928. myCode := GetResource('PROC', 1);
  929. myLongResult := CallExternal(myInteger, myLong, myCode^);
  930.  
  931. My Pascal is a little rusty, so I hope I'm not too far off.
  932.  
  933. -- 
  934. - ----------------------------------------------------------------------------
  935. Keith Rollin           ---            <Taligent .signature under construction>
  936. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  937.  
  938.  
  939.  
  940. ---------------------------
  941.  
  942. From: jwwalker@opusc.csd.scarolina.edu (Jim Walker)
  943. Subject: How do you write an MDEF that handles scrolling?
  944. Organization: Univ. of S. Carolina, Department of Mathematics
  945. Date: Wed, 29 Jan 1992 13:31:53 GMT
  946.  
  947.  
  948. Does anyone know where I can get sample code for an MDEF that handles
  949. pop-ups and scrolling?  Inside Mac is pretty sketchy on scrolling.
  950. Specifically, what are the low-memory globals AtMenuBottom and MBSaveLoc
  951. used for?  (I think I understand about TopMenuItem.)
  952.  
  953. The Pascal MDEF in the May '91 Snippets does not handle scrolling.  The
  954. skeleton MDEF in THINK Reference does not handle scrolling.  The UMPG does
  955. not discuss the subject.
  956. -- 
  957.   -- Jim Walker 76367.2271@compuserve.com  walkerj@math.scarolina.edu
  958.  
  959.  
  960.  
  961. - -------------------------
  962.  
  963. From: haynes@mace.cc.purdue.edu (Carl W. Haynes III)
  964. Subject:  How do you write an MDEF that handles scrolling?
  965. Date: 29 Jan 92 21:20:12 GMT
  966. Organization: Purdue University Computing Center
  967.  
  968. In article <1992Jan29.133153.16679@opusc.csd.scarolina.edu> walkerj@math.scarolina.edu writes:
  969. >
  970. >Does anyone know where I can get sample code for an MDEF that handles
  971. >pop-ups and scrolling?  Inside Mac is pretty sketchy on scrolling.
  972. >Specifically, what are the low-memory globals AtMenuBottom and MBSaveLoc
  973. >used for?  (I think I understand about TopMenuItem.)
  974.  
  975. The example MDEF in Dave Mark's "Macintosh C programming Promer Vol II"
  976. handles both scrolling and pop-ups. The example
  977. in the text of the book doesn't handle these, but if you look at the
  978. code in Appendix B, this code has been added.
  979.  
  980. carl
  981. haynes@mace.cc.purdue.edu
  982.  
  983.  
  984.  
  985. - -------------------------
  986.  
  987. From: phils@chaos.cs.brandeis.edu (Phil Shapiro)
  988. Subject:  How do you write an MDEF that handles scrolling?
  989. Date: 29 Jan 92 22:53:56 GMT
  990. Organization: Symantec Corp.
  991.  
  992. >>>>> On Wed, 29 Jan 1992 13:31:53 GMT, jwwalker@opusc.csd.scarolina.edu (Jim Walker) said:
  993.  
  994.  > Does anyone know where I can get sample code for an MDEF that
  995.  > handles pop-ups and scrolling?  Inside Mac is pretty sketchy on
  996.  > scrolling.  Specifically, what are the low-memory globals
  997.  > AtMenuBottom and MBSaveLoc used for?  (I think I understand about
  998.  > TopMenuItem.)
  999.  
  1000.  > The Pascal MDEF in the May '91 Snippets does not handle scrolling.
  1001.  > The skeleton MDEF in THINK Reference does not handle scrolling.
  1002.  > The UMPG does not discuss the subject.
  1003.  
  1004. Hi Jim,
  1005.  
  1006. How about the MDEF that Apple has released? It doesn't do pop-ups (I
  1007. think), but it does hierarchical menus and scrolling. It's on the
  1008. developer CDs, and you can ftp it from ftp.apple.com (in
  1009. dts/mac/defprocs.6.0.x). The readme there claims that it's from System
  1010. 6.0.4.
  1011.  
  1012.     -phil
  1013. - --
  1014.    Phil Shapiro                           Technical Support Analyst
  1015.    Language Products Group                     Symantec Corporation
  1016.         Internet: phils@chaos.cs.brandeis.edu
  1017. --
  1018.    Phil Shapiro                           Technical Support Analyst
  1019.    Language Products Group                     Symantec Corporation
  1020.         Internet: phils@chaos.cs.brandeis.edu
  1021.  
  1022.  
  1023.  
  1024. - -------------------------
  1025.  
  1026. From: keith@Apple.COM (Keith Rollin)
  1027. Subject:  How do you write an MDEF that handles scrolling?
  1028. Date: 30 Jan 92 23:29:08 GMT
  1029. Organization: Apple Computer Inc., Cupertino, CA
  1030.  
  1031. In article <PHILS.92Jan29175356@chaos.cs.brandeis.edu> phils@chaos.cs.brandeis.edu (Phil Shapiro) writes:
  1032. >>>>>> On Wed, 29 Jan 1992 13:31:53 GMT, jwwalker@opusc.csd.scarolina.edu (Jim Walker) said:
  1033. >
  1034. > > Does anyone know where I can get sample code for an MDEF that
  1035. > > handles pop-ups and scrolling?  Inside Mac is pretty sketchy on
  1036. > > scrolling.  Specifically, what are the low-memory globals
  1037. > > AtMenuBottom and MBSaveLoc used for?  (I think I understand about
  1038. > > TopMenuItem.)
  1039. >
  1040. > > The Pascal MDEF in the May '91 Snippets does not handle scrolling.
  1041. > > The skeleton MDEF in THINK Reference does not handle scrolling.
  1042. > > The UMPG does not discuss the subject.
  1043. >
  1044. >How about the MDEF that Apple has released? It doesn't do pop-ups (I
  1045. >think), but it does hierarchical menus and scrolling. It's on the
  1046. >developer CDs, and you can ftp it from ftp.apple.com (in
  1047. >dts/mac/defprocs.6.0.x). The readme there claims that it's from System
  1048. >6.0.4.
  1049.  
  1050. I'm pretty sure the Apple provided MDEF source handles popups, since
  1051. it's straight out of the source code used to build the System. However,
  1052. since it's from 6.0.4, it doesn't handle the new 7.0 things, like true
  1053. gray for disabled items and help balloons.
  1054.  
  1055. -- 
  1056. - ----------------------------------------------------------------------------
  1057. Keith Rollin           ---            <Taligent .signature under construction>
  1058. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  1059.  
  1060.  
  1061.  
  1062. - -------------------------
  1063.  
  1064. From: keith@Apple.COM (Keith Rollin)
  1065. Subject:  How do you write an MDEF that handles scrolling?
  1066. Date: 30 Jan 92 23:29:08 GMT
  1067. Organization: Apple Computer Inc., Cupertino, CA
  1068.  
  1069. In article <PHILS.92Jan29175356@chaos.cs.brandeis.edu> phils@chaos.cs.brandeis.edu (Phil Shapiro) writes:
  1070. >>>>>> On Wed, 29 Jan 1992 13:31:53 GMT, jwwalker@opusc.csd.scarolina.edu (Jim Walker) said:
  1071. >
  1072. > > Does anyone know where I can get sample code for an MDEF that
  1073. > > handles pop-ups and scrolling?  Inside Mac is pretty sketchy on
  1074. > > scrolling.  Specifically, what are the low-memory globals
  1075. > > AtMenuBottom and MBSaveLoc used for?  (I think I understand about
  1076. > > TopMenuItem.)
  1077. >
  1078. > > The Pascal MDEF in the May '91 Snippets does not handle scrolling.
  1079. > > The skeleton MDEF in THINK Reference does not handle scrolling.
  1080. > > The UMPG does not discuss the subject.
  1081. >
  1082. >How about the MDEF that Apple has released? It doesn't do pop-ups (I
  1083. >think), but it does hierarchical menus and scrolling. It's on the
  1084. >developer CDs, and you can ftp it from ftp.apple.com (in
  1085. >dts/mac/defprocs.6.0.x). The readme there claims that it's from System
  1086. >6.0.4.
  1087.  
  1088. I'm pretty sure the Apple provided MDEF source handles popups, since
  1089. it's straight out of the source code used to build the System. However,
  1090. since it's from 6.0.4, it doesn't handle the new 7.0 things, like true
  1091. gray for disabled items and help balloons.
  1092.  
  1093. -- 
  1094. - ----------------------------------------------------------------------------
  1095. Keith Rollin           ---            <Taligent .signature under construction>
  1096. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  1097.  
  1098.  
  1099.  
  1100. ---------------------------
  1101.  
  1102. From: S_HAERDLE@iravcl.ira.uka.de (|S| Tilman Haerdle)
  1103. Subject: Select Directory dialog
  1104. Date: 29 Jan 1992 13:13:54 GMT
  1105. Organization: University of Karlsruhe, FRG (Informatik Rechnerabteilung)
  1106.  
  1107. Hi,
  1108.  
  1109. i would like to implement a dialog box to allow the user choosing a directory
  1110. similar to the standard "open file"-dialog. mpw poses such a dialog, when i have
  1111. installed MacApp (dialog : "Where is your MacApp folder
  1112.  
  1113. anyone out there who has customized sfpgetfile or has done it using
  1114. MacApp 2.0 ???????
  1115.  
  1116. thanks,
  1117.  
  1118. tilman
  1119.  
  1120.  
  1121.  
  1122.  
  1123. - -------------------------
  1124.  
  1125. From: keith@Apple.COM (Keith Rollin)
  1126. Subject:  Select Directory dialog
  1127. Date: 30 Jan 92 22:40:06 GMT
  1128. Organization: Apple Computer Inc., Cupertino, CA
  1129.  
  1130. In article <koda4iINNhe9@iraul1.ira.uka.de> S_HAERDLE@iravcl.ira.uka.de (|S| Tilman Haerdle) writes:
  1131. >Hi,
  1132. >
  1133. >i would like to implement a dialog box to allow the user choosing a directory
  1134. >similar to the standard "open file"-dialog. mpw poses such a dialog, when i have
  1135. >installed MacApp (dialog : "Where is your MacApp folder
  1136. >
  1137. >anyone out there who has customized sfpgetfile or has done it using
  1138. >MacApp 2.0 ???????
  1139.  
  1140. Mac DTS Sample Code #18: Stdfile addresses this issue. You can get this
  1141. sample code from Apple's ftp site (ftp.apple.com), from APDA, or from
  1142. many other ftp sites and BBS's.
  1143.  
  1144. The sample code sited customizes SFPGetFile. While it was not written
  1145. with MacApp in mind, there is no reason why you cannot incorporate into
  1146. your MacApp program.
  1147.  
  1148. -- 
  1149. - ----------------------------------------------------------------------------
  1150. Keith Rollin           ---            <Taligent .signature under construction>
  1151. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  1152.  
  1153.  
  1154.  
  1155. - -------------------------
  1156.  
  1157. From: keith@Apple.COM (Keith Rollin)
  1158. Subject:  Select Directory dialog
  1159. Date: 30 Jan 92 22:40:06 GMT
  1160. Organization: Apple Computer Inc., Cupertino, CA
  1161.  
  1162. In article <koda4iINNhe9@iraul1.ira.uka.de> S_HAERDLE@iravcl.ira.uka.de (|S| Tilman Haerdle) writes:
  1163. >Hi,
  1164. >
  1165. >i would like to implement a dialog box to allow the user choosing a directory
  1166. >similar to the standard "open file"-dialog. mpw poses such a dialog, when i have
  1167. >installed MacApp (dialog : "Where is your MacApp folder
  1168. >
  1169. >anyone out there who has customized sfpgetfile or has done it using
  1170. >MacApp 2.0 ???????
  1171.  
  1172. Mac DTS Sample Code #18: Stdfile addresses this issue. You can get this
  1173. sample code from Apple's ftp site (ftp.apple.com), from APDA, or from
  1174. many other ftp sites and BBS's.
  1175.  
  1176. The sample code sited customizes SFPGetFile. While it was not written
  1177. with MacApp in mind, there is no reason why you cannot incorporate into
  1178. your MacApp program.
  1179.  
  1180. -- 
  1181. - ----------------------------------------------------------------------------
  1182. Keith Rollin           ---            <Taligent .signature under construction>
  1183. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  1184.  
  1185.  
  1186.  
  1187. ---------------------------
  1188.  
  1189. From: e-sink@uiuc.edu (Eric W. Sink)
  1190. Subject: Where's that code frag that finds the app file ?
  1191. Date: 29 Jan 92 16:45:16 GMT
  1192. Organization: University of Illinois at Urbana-Champaign
  1193.  
  1194. People have asked this before, but I need that piece of code which
  1195. finds the location of its own application file.  I want to locate
  1196. the app and search in that directory for some files.
  1197.  
  1198. Wasn't it something like CurResFile() and then some PBstuffCalls ?
  1199.  
  1200. Is in the UMPG ?  (I know I've seen it somewhere... :-)
  1201.  
  1202. adThanksvance.
  1203.  
  1204. -- 
  1205. Eric W. Sink,  Spatial Analysis and Systems Team
  1206. USACERL, P.O. Box 9005, Champaign, IL 61826-9005
  1207. 1-800-USA-CERL x449,   e-sink@uiuc.edu
  1208.  
  1209.  
  1210.  
  1211. - -------------------------
  1212.  
  1213. From: keith@Apple.COM (Keith Rollin)
  1214. Subject:  Where's that code frag that finds the app file ?
  1215. Date: 30 Jan 92 22:55:09 GMT
  1216. Organization: Apple Computer Inc., Cupertino, CA
  1217.  
  1218. In article <1992Jan29.164516.6306@sunb10.cs.uiuc.edu> e-sink@uiuc.edu writes:
  1219. >People have asked this before, but I need that piece of code which
  1220. >finds the location of its own application file.  I want to locate
  1221. >the app and search in that directory for some files.
  1222. >
  1223. >Wasn't it something like CurResFile() and then some PBstuffCalls ?
  1224. >
  1225. >Is in the UMPG ?  (I know I've seen it somewhere... :-)
  1226.  
  1227. Probably Inside Mac. The call you want is HGetVol. Call it when
  1228. your application starts up, and before you change the default
  1229. directory (if you do that at all).
  1230.  
  1231. -- 
  1232. - ----------------------------------------------------------------------------
  1233. Keith Rollin           ---            <Taligent .signature under construction>
  1234. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  1235.  
  1236.  
  1237.  
  1238. - -------------------------
  1239.  
  1240. From: jmatthews@desire.wright.edu
  1241. Subject:  Where's that code frag that finds the app file ?
  1242. Date: 1 Feb 92 04:09:22 GMT
  1243. Organization: Wright State University
  1244.  
  1245. In article <62301@apple.Apple.COM>, keith@Apple.COM (Keith Rollin) writes:
  1246. > In article <1992Jan29.164516.6306@sunb10.cs.uiuc.edu> e-sink@uiuc.edu writes:
  1247. >>People have asked this before, but I need that piece of code which
  1248. >>finds the location of its own application file.  I want to locate
  1249. >>the app and search in that directory for some files.
  1250. >>
  1251. >>Wasn't it something like CurResFile() and then some PBstuffCalls ?
  1252. >>
  1253. >>Is in the UMPG ?  (I know I've seen it somewhere... :-)
  1254. > Probably Inside Mac. The call you want is HGetVol. Call it when
  1255. > your application starts up, and before you change the default
  1256. > directory (if you do that at all).
  1257.  
  1258. Also call the Segment Loader's GetAppParms to find out what the user has
  1259. (re)named your application.
  1260.  
  1261. o----------------------------------------------------------------------------o
  1262. | John B. Matthews, jmatthews@desire.wright.edu, disclaimer:= myViews <> WSU |
  1263. | "I'm a commensal .sig virus, indistinguishable from an ordinary organelle."|
  1264. o----------------------------------------------------------------------------o
  1265.  
  1266.  
  1267.  
  1268. - -------------------------
  1269.  
  1270. From: keith@Apple.COM (Keith Rollin)
  1271. Subject:  Where's that code frag that finds the app file ?
  1272. Date: 30 Jan 92 22:55:09 GMT
  1273. Organization: Apple Computer Inc., Cupertino, CA
  1274.  
  1275. In article <1992Jan29.164516.6306@sunb10.cs.uiuc.edu> e-sink@uiuc.edu writes:
  1276. >People have asked this before, but I need that piece of code which
  1277. >finds the location of its own application file.  I want to locate
  1278. >the app and search in that directory for some files.
  1279. >
  1280. >Wasn't it something like CurResFile() and then some PBstuffCalls ?
  1281. >
  1282. >Is in the UMPG ?  (I know I've seen it somewhere... :-)
  1283.  
  1284. Probably Inside Mac. The call you want is HGetVol. Call it when
  1285. your application starts up, and before you change the default
  1286. directory (if you do that at all).
  1287.  
  1288. -- 
  1289. - ----------------------------------------------------------------------------
  1290. Keith Rollin           ---            <Taligent .signature under construction>
  1291. Disclaimer: Pretty soon, I really _won't_ be speaking for Apple...
  1292.  
  1293.  
  1294.  
  1295. ---------------------------
  1296.  
  1297. End of C.S.M.P. Digest
  1298. **********************
  1299.